home *** CD-ROM | disk | FTP | other *** search
- Subject: fselect patch... (repost)
- Date: Thu, 23 Jun 94 9:33:18 +0200
- From: Torsten Scherer <itschere@techfak.uni-bielefeld.de>
-
- Huhu!
-
- I've been reported that my patch for exceptional conditions has had no
- `tabs' in it. I must admit that I've only noticed it when I've read my own
- mail from the list and assume that I've had some problems with my
- communication program.
-
- So, for those of you who felt disturbed by this, here it is again, with
- the `better' value for FIOEXCEPT and a bit nicer, I hope... :-)
-
- ciao,
- TeSche
- --
- Torsten Scherer (TeSche, Schiller...)
- Faculty of Technology, University of Bielefeld, Germany, Europe, Earth...
- | Use any of "finger itschere@129.70.131.2-15" for adresses and more. |
- | Last updated: 14. April 1994. |
-
-
- --- file.h.orig Sun Jun 19 17:54:16 1994
- +++ file.h Thu Jun 23 09:20:02 1994
- @@ -340,6 +340,7 @@
- #define FSTAT (('F'<< 8) | 0) /* handled by kernel */
- #define FIONREAD (('F'<< 8) | 1)
- #define FIONWRITE (('F'<< 8) | 2)
- +#define FIOEXCEPT (('F'<< 8) | 5)
- #define TIOCGETP (('T'<< 8) | 0)
- #define TIOCSETN (('T'<< 8) | 1)
- #define TIOCGETC (('T'<< 8) | 2)
- --- dosfile.c.orig Sun Jun 19 17:54:26 1994
- +++ dosfile.c Sun Jun 19 17:54:24 1994
- @@ -954,11 +954,11 @@
- * integers containing bitmasks that describe which file descriptors
- * we're interested in. These masks are changed to represent which
- * file descriptors actually have data waiting (rfd), are ready to
- - * output (wfd), or have exceptional conditions (xfd -- currently
- - * ignored). If timeout is 0, fselect blocks until some file descriptor
- - * is ready; otherwise, it waits only "timeout" milliseconds.
- - * Return value: number of file descriptors that are available for
- - * reading/writing; or a negative error number.
- + * output (wfd), or have exceptional conditions (xfd). If timeout is 0,
- + * fselect blocks until some file descriptor is ready; otherwise, it
- + * waits only "timeout" milliseconds. Return value: number of file
- + * descriptors that are available for reading/writing; or a negative
- + * error number.
- */
-
- /* helper function for time outs */
- @@ -974,7 +974,7 @@
- unsigned timeout;
- long *rfdp, *wfdp, *xfdp;
- {
- - long rfd, wfd;
- + long rfd, wfd, xfd;
- long mask, bytes;
- int i, count;
- FILEPTR *f;
- @@ -982,9 +982,6 @@
- TIMEOUT *t;
- short sr;
-
- - if (xfdp)
- - *xfdp = 0;
- -
- if (rfdp) {
- rfd = *rfdp; *rfdp = 0;
- }
- @@ -995,14 +992,19 @@
- }
- else
- wfd = 0;
- + if (xfdp) {
- + xfd = *xfdp; *xfdp = 0;
- + }
- + else
- + xfd = 0;
-
- - TRACE(("Fselect(%u, %lx, %lx)", timeout, rfd, wfd));
- + TRACE(("Fselect(%u, %lx, %lx, %lx)", timeout, rfd, wfd, xfd));
- p = curproc; /* help the optimizer out */
-
- /* first, validate the masks */
- mask = 1L;
- for (i = 0; i < MAX_OPEN; i++) {
- - if ( ((rfd & mask) || (wfd & mask)) && !(p->handle[i]) ) {
- + if ( ((rfd & mask) || (wfd & mask) || (xfd & mask)) && !(p->handle[i]) ) {
- DEBUG(("Fselect: invalid handle: %d", i));
- return EIHNDL;
- }
- @@ -1044,6 +1046,17 @@
- *wfdp |= mask;
- }
- }
- + if (xfd & mask) {
- + f = p->handle[i];
- +/* tesche: anybody worried about using O_RDWR for exceptional data? ;) */
- + if ((*f->dev->select)(f, (long)p, O_RDWR) == 1) {
- +/* tesche: for old device drivers, which don't understand this
- + * call, this will never be true and therefore won't disturb us here.
- + */
- + count++;
- + *xfdp |= mask;
- + }
- + }
- mask = mask << 1L;
- }
-
- @@ -1106,6 +1119,20 @@
- }
- }
- }
- + if (xfd & mask) {
- + f = p->handle[i];
- + if (f) {
- +/* tesche: since old device drivers won't understand this call,
- + * we set up `no exceptional condition' as default.
- + */
- + bytes = 0L;
- + (void)(*f->dev->ioctl)(f, FIOEXCEPT,&bytes);
- + if (bytes > 0) {
- + *xfdp |= mask;
- + count++;
- + }
- + }
- + }
- mask = mask << 1L;
- }
- }
- @@ -1125,6 +1152,11 @@
- if (f)
- (*f->dev->unselect)(f, (long)p, O_WRONLY);
- }
- + if (xfd & mask) {
- + f = p->handle[i];
- + if (f)
- + (*f->dev->unselect)(f, (long)p, O_RDWR);
- + }
- mask = mask << 1L;
- }
-
- --- biosfs.c.orig Mon Jun 20 14:28:52 1994
- +++ biosfs.c Mon Jun 20 14:33:36 1994
- @@ -1090,11 +1090,12 @@
- FILEPTR *f; int mode; void *buf;
- {
- UNUSED(f);
- - if (mode == FIONREAD) {
- + if (mode == FIONREAD)
- *((long *)buf) = 0;
- - }
- else if (mode == FIONWRITE)
- *((long *)buf) = 1;
- + else if (mode == FIOEXCEPT)
- + *((long *)buf) = 0;
- else
- return EINVFN;
- return 0;
- @@ -1130,8 +1131,10 @@
- int mode;
- {
- UNUSED(f); UNUSED(p);
- - UNUSED(mode);
- - return 1; /* we're always ready to read/write */
- + if ((mode == O_RDONLY) || (mode == O_WRONLY))
- + return 1; /* we're always ready to read/write */
- +
- + return 0; /* other things we don't care about */
- }
-
- void ARGS_ON_STACK
- @@ -1339,6 +1342,9 @@
- else
- *r = 0;
- break;
- + case FIOEXCEPT:
- + *r = 0;
- + break;
- case TIOCFLUSH:
- {
- int oldmap;
- @@ -1878,6 +1884,10 @@
- if (r < 0) r += MOUSESIZ;
- *((long *)buf) = r;
- }
- + else if (mode == FIONWRITE)
- + *((long *)buf) = 0;
- + else if (mode == FIOEXCEPT)
- + *((long *)buf) = 0;
- else
- return EINVFN;
- return 0;
- @@ -1891,8 +1901,12 @@
- {
- UNUSED(f);
-
- - if (mode != O_RDONLY)
- - return 1; /* we can always take output :-) */
- + if (mode != O_RDONLY) {
- + if (mode == O_WRONLY)
- + return 1; /* we can always take output :-) */
- + else
- + return 0; /* but don't care for anything else */
- + }
-
- if (mousetail - mousehead)
- return 1; /* input waiting already */
- --- fasttext.c.orig Mon Jun 20 14:28:38 1994
- +++ fasttext.c Mon Jun 20 14:30:48 1994
- @@ -1322,6 +1322,9 @@
- else if (mode == FIONWRITE) {
- *r = 1;
- }
- + else if (mode == FIOEXCEPT) {
- + *r = 0;
- + }
- else if (mode == TIOCFLUSH) {
- /* BUG: this should flush the input/output buffers */
- return 0;
- --- pipefs.c.orig Mon Jun 20 14:35:42 1994
- +++ pipefs.c Mon Jun 20 14:37:16 1994
- @@ -782,6 +782,9 @@
- }
- *((long *) buf) = r;
- break;
- + case FIOEXCEPT:
- + *((long *) buf) = 0;
- + break;
- case F_SETLK:
- case F_SETLKW:
- lck = (struct flock *)buf;
- --- procfs.c.orig Mon Jun 20 14:37:30 1994
- +++ procfs.c Mon Jun 20 14:38:08 1994
- @@ -693,6 +693,9 @@
- case FIONWRITE:
- *((long *)buf) = 1L; /* we're always ready for i/o */
- return 0;
- + case FIOEXCEPT:
- + *((long *)buf) = 0L;
- + return 0;
- default:
- DEBUG(("procfs: bad Fcntl command"));
- }
- --- tosfs.c.orig Mon Jun 20 14:34:46 1994
- +++ tosfs.c Mon Jun 20 14:35:04 1994
- @@ -1314,6 +1314,9 @@
- case FIONWRITE:
- *((long *)buf) = 1;
- return 0;
- + case FIOEXCEPT:
- + *((long *)buf) = 0;
- + return 0;
- case F_SETLK:
- case F_SETLKW:
- case F_GETLK:
-